package com.tabl;

import java.io.IOException;

import org.apache.poi.ss.usermodel.CellValue;

public class Main {
    // 假的IOException
    public static void main(String[] args) throws IOException {
        FormulaLib formulaLib = new FormulaLib();
        formulaLib.load();
        CellValue result;
        try {
            // !应catch
            result = formulaLib.calc("func.SUMIF({A,B,C,D,A}, A, {1,1,1,1,2})");
        } catch (Exception e) {
            System.out.println("!!!!error: " + e.getMessage());
        }

        try {
            // !应正常输出 3
            result = formulaLib.calc("func.SUMIF(\"{A,B,C,D,A}\", \"A\", \"{1,1,1,1,2}\")");
            switch (result.getCellType()) {
                case BOOLEAN:
                    System.out.println(result.getBooleanValue());
                    break;
                case NUMERIC:
                    System.out.println(result.getNumberValue());
                    break;
                case STRING:
                    System.out.println(result.getStringValue());
                    break;
                default:
                    break;
            }
        } catch (Exception e) {
        }

        formulaLib.unload();
    }
}
